In designing a product, a USB (Universal Serial BUS, universal serial bus) interface of a terminal device is usually used to connect to accessories to extend functions. USB OTG (On-The-Go) is a main outbound communication interface of an internal processor of the terminal device. With respect to implementation, the USB OTG automatically switches between a host (master device) working mode and a device (slave device) working mode by using a USB interface ID (Identity, identity) signal level. When the ID signal has a low level, the OTG working mode of the terminal device is set to a host mode. In this case, 5 V power needs to be output to an external accessory through a VBUS (USB voltage line) power supply of the terminal device; or, when an ID signal is floating or has a high level and the OTG working mode of the terminal device is set to a Device mode, the VBUS power supply of the terminal device needs to input power from the outside for the purposes of charging a battery of the terminal device and powering the system.
In the process of implementing the present invention, the inventor finds that the prior art has at least the following disadvantages: In the solution described above, the power output needs to be bound to the host mode; or, the power input needs to be bound to the Device mode. That is, in the existing implementing solution, the power input or output of a terminal device is restricted by the OTG working mode binding of the terminal device.